1. Field of the Invention
The present invention relates generally to displaying video and computer images, and more specifically, to converting colors in the images from one color space to an another color space.
2. Related Art
An image to be displayed on a monitor or television screen is represented by a matrix of points referred to as pixels. The pixels are scanned across the monitor or screen both horizontally and vertically. Each pixel has an associated color that is typically represented by a particular set of values of three different components. The three different components used to represent the color define a color space.
The color space is a mathematical representation of a set of colors. Several color spaces are presently used in various different applications. An RGB color space represents color as levels of red (R), green (G), and blue (B). The RGB color space is used in color computer graphics. A YUV color space represents color as intensity (Y) and two color difference components (U, V). The YUV color space is used in television equipment and was developed to accommodate both black-and-white and color televisions. A YCrCb color space (a scaled and offset version of the YUV color space color) also represents color as intensity (Y) and two color difference components (Cr,Cb). The YCrCb color space was developed as part of a world-wide digital component video standard. Other color spaces include CMYK, HSI, and HSV.
Each color space has been developed according to various industry standards. These standards define a valid range of values for each of the respective components referred to as a valid component range. These standards also define equations and coefficients to be used to convert the color of a pixel from one color space to another color space. For example, conversion between the RGB color space and the YCrCb color space is accomplished with a well established set of equations.
Conversion of the color between various color spaces is necessary as the lines between digital computer equipment and television equipment becomes blurred. For example, multimedia systems employing a computer system to display video images must convert the video image into an image displayable on the computer. The multimedia system must convert the video image from the YCrCb color space to a computer image in the RGB color space.
One problem associated with this conversion is due to the valid component ranges of the components in the respective color spaces. The valid component ranges in a particular color space can be represented as a rectangular cube in three dimensional space. Each color in the particular color space is defined by a set of three points referred to as a triplet, within the rectangular cube. A triplet having each of its components within the valid component range of the color space, and hence, within the cube of the color space, is referred to as a valid triplet. A triplet having one or more components outside the valid component range of the color space, or outside the cube of the color space, is referred to as an invalid triplet.
A cube representing the RGB color space (RGB cube) lies entirely within a cube representing the YCrCb color space (YCrCb cube). Thus, every valid RGB triplet corresponds to a valid YCrCb triplet, but not every valid YCrCb triplet corresponds to a valid RGB triplet because a large percentage of valid YCrCb triplets lie outside the RGB cube.
One method conventional systems have used to address invalid RGB triplets is to clip, clamp, or truncate each component to its maximum (or minimum) value. This method produces an undesirable color shift that, in many cases, is readily apparent to the viewer.
Another method conventional systems have used to address invalid RGB triplets is to choose RGB values that hold luminance and hue constant and reduce saturation until the invalid RGB triplet becomes valid. This method shifts bright colors to white and dark colors to black. As a result, the overall displayed image becomes more black and white. This effect is also readily apparent to the viewer.
A second problem associated with the conversion of a color between color spaces is due to conventional systems attempting to solve the first problem. Once a conventional system has adjusted, or compensated, the invalid RGB triplet to be within the valid RGB component range, the original YCrCb triplet can not be subsequently recovered from the adjusted, or compensated, RGB triplet. Thus, in conventional systems, not only is some color information lost during the conversion, but conventional systems do not provide any means for storing or recovering the lost color information.
What is needed is a system and method for color space conversion that preserves the quality of the original image with respect to the viewer without the undesirable effects introduced by conventional systems and that allows the original image to be subsequently recovered without loss of information.